#include <program_manager.h>
#include <string.h>

void ProgramManager::add(const char * tag, Program * p)
{
	mMapPrograms.insert(std::pair<const char *, Program *>(tag, p));
}

Program * ProgramManager::getProgram(const char * by_tag)
{
	//return mMapPrograms[by_tag];
	std::map<const char *, Program *>::iterator it;
	for (it=mMapPrograms.begin(); it!=mMapPrograms.end(); ++it)
	{
		if (strcmp(by_tag, it->first) == 0)
		{
			return it->second;
		}
	}
	return NULL;
}

void ProgramManager::debug()
{
	std::map<const char *, Program *>::iterator it;
for (it=mMapPrograms.begin(); it!=mMapPrograms.end(); ++it)
	printf("TAGS %s Programs %d\n", it->first, it->second);
    //std::cout << it->first << " => " << it->second << '\n';
}
